<?php

declare(strict_types=1);

namespace App\Controller\Backend;

use App\Model\WebLog;
use App\Resource\Backend\BaseResource;
use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;

class WebLogs extends AbstractController
{
    public function index(RequestInterface $request, ResponseInterface $response)
    {
        $where = [];
        if ($request->input('user_name')) {
            $where[] = ['user_name', '=', $request->input('user_name')];
        }
        $list = WebLog::where($where)->orderBy('id', 'desc')->paginate();
        return BaseResource::collection($list)->additional(['code' => 0, 'msg' => '成功']);
    }
}
